#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "AMMimeUtils.h"

#define mh1 "=?iso-8859-1?Q?A mail header =7Bwith special chars in=7D"
#define teststr "Another small text for testing {just for demo}..."

int main(int argc, char* argv[])
{
  //let's try to decode an encoded mailheader
  char *s = (char*)calloc(100, sizeof(char));
  memcpy(s, mh1,strlen(mh1));
  s = MimeDecodeMailHeaderField(s);
  printf("%s\r\n", s);
  free(s);

  //let's try to Quoted-Printable encode teststr, and decode it again...
  s = (char*)calloc(100, sizeof(char));
  memcpy(s, teststr,strlen(teststr));
  CQPUtils qp;
  char *result = qp.Encode(s);
  printf("%s\r\n", result);
  char *result2 = qp.Decode(result);
  printf("%s\r\n", result2);
  free(s);
  free(result);
  free(result2);

  //let's try to Base64 encode teststr, and decode it again...
  s = (char*)calloc(100, sizeof(char));
  memcpy(s, teststr, strlen(teststr));
  CBase64Utils bu;
  int length = strlen(s);
  result = bu.Encode(s, length);
  printf("%s\r\n", result);
  length = strlen(result);
  result2 = bu.Decode(result, &length);
  printf("%s\r\n", result2);
  free(s);
  free(result);
  free(result2);

	return 0;
}
